import { _decorator, Component, Node } from 'cc';
import { Dictionary } from '../utils/Dictionary';
import { roleEquipEnum } from '../Enum';
import { StartSceneGameMgr } from './StartSceneGameMgr';
import { keepOneDecimalFull2 } from '../utils/utils';
import { loading } from '../loading';
import { UserInfo } from './UserInfo';
const { ccclass, property } = _decorator;

@ccclass('Equip')
export class Equip {
   
    equipId;
    equipType;
    equipTp;
    enhanceLevel;
    ownerRoleId=-1;

    initData(data) {
        this.equipType=data.equipType;
        this.enhanceLevel=data.enhanceLevel;
        this.equipId=data.equipId;
        this.ownerRoleId=data.ownerRoleId||-1;

        this.equipTp=UserInfo.equipCongfiDic.get(this.equipType);
    }

   
    get attackAddition() {
        let res;
        res = parseInt(this.equipTp.attack) * (this.enhanceLevel+1)
        return res
    }

    get frequencyAddition() {//加上，返回的是小数
        // let res;
        // res =parseInt(this.equipTp.frequency) * this.enhanceLevel*0.05
        // return -(res)
        return -(this.equipTp.frequency)
    }
    get criticalHitAddition() {//加上，返回的是小数
        // let res;
        // res =parseInt(this.equipTp.criticalHit) * this.enhanceLevel*0.05
        // return res
        return this.equipTp.criticalHit
    }

    get nextLevelAttackAddition(){
        let res;
        res = parseInt(this.equipTp.attack) * (this.enhanceLevel+2)
        return res
    }
    // get nextLevelFrequencyAddition() {//加上，返回的是小数
    //     let res;
    //     res =parseInt(this.equipTp.frequency) * (this.enhanceLevel+1)*0.05
    //     return -(res)
    // }
    // get nextLevelCriticalHitAddition() {//加上，返回的是小数
    //     let res;
    //     res =parseInt(this.equipTp.criticalHit) * (this.enhanceLevel+1)*0.05
    //     return res
    // }

    get EnhanceCost(){
        let res;
        res=(this.enhanceLevel+1)*20
        return res;
    }

    get salvageGet() {
        let res;
        res = (this.enhanceLevel+1)*5 + ((this.equipTp.quality+1)*25)
        return res;
    }

    get getEnhanceSucceedProbability(){//强化成功概率
        let res=100;

        if (this.enhanceLevel<=5) {
            res=100;
        }
        else {
            res = 100-((this.enhanceLevel-5)*5)//6级，百分之95,7级百分之90，以此类推
        }

        if (res<40) {//最低概率百分之40
            res=40;
        }

        return res
    }
    



}


